home *** CD-ROM | disk | FTP | other *** search
- //
- // $Log: Timer.c,v $
- // Revision 1.4 1994/07/11 21:54:10 hakan
- // Mainly cosmetic changes
- //
- // Revision 1.3 1994/06/20 00:07:14 hakan
- // Returnes TimeRequests are primed with 0.2 seconds
- //
- // Revision 1.2 1994/06/19 15:22:34 hakan
- // Fini, for starters
- //
- // Revision 1.1 1994/06/19 15:00:12 hakan
- // Initial revision
- //
- //
-
- static char* RCSId = "$Id: Timer.c,v 1.4 1994/07/11 21:54:10 hakan Exp $";
-
-
-
- static short TimerDevFlag = 0;
- static struct timerequest* TimerReq = NULL;
- static struct MsgPort* TimerPort = NULL;
- static struct Library* TimerBase = NULL;
-
-
-
- BOOL CreateTimer (void)
- {
- if (TimerPort = (struct MsgPort *) CreateMsgPort ())
- {
- if (TimerReq = (struct timerequest *) CreateIORequest (TimerPort, sizeof (struct timerequest)))
- {
- if (TimerDevFlag = !OpenDevice (TIMERNAME, UNIT_MICROHZ, (struct IORequest *) TimerReq, 0L))
- {
- TimerBase = (struct Library *) TimerReq->tr_node.io_Device;
-
- TimerReq->tr_node.io_Message.mn_ReplyPort = TimerPort;
- TimerReq->tr_node.io_Command = TR_ADDREQUEST;
- TimerReq->tr_node.io_Flags = 0L;
- TimerReq->tr_node.io_Error = 0L;
-
- return (TRUE);
- }
- }
- }
-
- return (FALSE);
- }
-
-
-
- void DestroyTimer (void)
- {
- if (TimerReq)
- {
- AbortIO ((struct IORequest*) TimerReq);
- // WaitIO ((struct IORequest*) TimerReq);
- }
-
- if (TimerDevFlag)
- {
- CloseDevice ((struct IORequest *) TimerReq);
- }
-
- if (TimerReq)
- {
- DeleteIORequest (TimerReq);
- }
-
- if (TimerPort)
- {
- DeleteMsgPort (TimerPort);
- }
- }
-
-
-
- struct IORequest* TimeRequest (void)
- {
- TimerReq->tr_time.tv_secs = 0;
- TimerReq->tr_time.tv_micro = 200000; // 1E6 / 5
-
- return (TimerReq);
- }
-
-
-
- struct MsgPort* TimePort (void)
- {
- return (TimerPort);
- }
-